package com.example.logistics_oa.controller;


import com.example.comment_oa.pojos.xinzi.*;
import com.example.comment_oa.response.AjaxResponse;
import com.example.logistics_oa.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/logisticsOa")
@CrossOrigin
public class JiBenHeSuanController {
    @Autowired
    JibenXinzijisuanService jibenXinzijisuanService;
    @Autowired
    JibenKaoqinhesuanService jibenKaoqinhesuanService;
    @Autowired
    JibenButiejisuanService jibenButiejisuanService;
    @Autowired
    JibenWuxianyijinService jibenWuxianyijinService;
    @Autowired
    JibenQitajineService jibenQitajineService;
    @Autowired
    JibenGongzidanService jibenGongzidanService;
    @Autowired
    ShsalaryZhubiaoService shsalaryZhubiaoService;

    @PostMapping("/fagongzi/{jibenId}")
    public AjaxResponse fagongzi(@PathVariable("jibenId") String jibenId){
        List<JibenXinzijisuan> jibenXinzijisuans = jibenXinzijisuanService.selectByIdAndSend(jibenId, 0);
        List<JibenKaoqinhesuan> jibenKaoqinhesuans = jibenKaoqinhesuanService.selectByIdAndSend(jibenId, 0);
        List<JibenButiejisuan> jibenButiejisuans = jibenButiejisuanService.selectByIdAndSend(jibenId, 0);
        List<JibenWuxianyijin> jibenWuxianyijins = jibenWuxianyijinService.selectByIdAndSend(jibenId, 0);
        List<JibenQitajine> jibenQitajines = jibenQitajineService.selectByIdAndSend(jibenId, 0);
        List<JibenGongzidan> jibenGongzidans = jibenGongzidanService.selectByIdAndSend(jibenId, 0);
        if(jibenXinzijisuans.isEmpty() && jibenKaoqinhesuans.isEmpty() && jibenButiejisuans.isEmpty()&&jibenWuxianyijins.isEmpty() &&jibenQitajines.isEmpty() && jibenGongzidans.isEmpty()){
            //全部都通过审核的在这里
            shsalaryZhubiaoService.updatezhubiaoStatus(jibenId);
            jibenGongzidanService.updateShiJian(jibenId);
            return  AjaxResponse.success();


        }else {
            return  AjaxResponse.dosentexit();
        }

    }

}
